using Boo.Lang;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using UnityEngine;

[Serializable]
public class winlosedraw : MonoBehaviour
{
	[Serializable]
	[CompilerGenerated]
	internal sealed class _0024state_0024503 : GenericGenerator<WaitForSeconds>
	{
		internal winlosedraw _0024self__0024505;

		public _0024state_0024503(winlosedraw self_)
		{
			_0024self__0024505 = self_;
		}

		public override IEnumerator<WaitForSeconds> GetEnumerator()
		{
			return new _0024(_0024self__0024505);
		}
	}

	[Serializable]
	[CompilerGenerated]
	internal sealed class _0024find_0024506 : GenericGenerator<WaitForSeconds>
	{
		internal winlosedraw _0024self__0024508;

		public _0024find_0024506(winlosedraw self_)
		{
			_0024self__0024508 = self_;
		}

		public override IEnumerator<WaitForSeconds> GetEnumerator()
		{
			return new _0024(_0024self__0024508);
		}
	}

	public spin Player;

	public spin AI1;

	public spin AI2;

	public spin AI3;

	public GameObject win;

	public GameObject lose;

	public GameObject draw;

	public int stat;

	public threeroundsystem threeround;

	public bool twoplayer;

	public int defGravity;

	public winlosedraw()
	{
		defGravity = 1;
	}

	public void Start()
	{
		if (Input.deviceOrientation != DeviceOrientation.FaceDown)
		{
			defGravity = 0;
		}
		if (twoplayer)
		{
			StartCoroutine(find());
		}
		GameObject obj = GameObject.Find("aback 1(Clone)");
		UnityEngine.Object.Destroy(obj);
	}

	public void wld()
	{
		if (Input.deviceOrientation == DeviceOrientation.FaceUp || Input.deviceOrientation == DeviceOrientation.Portrait || Input.deviceOrientation == DeviceOrientation.PortraitUpsideDown || Input.deviceOrientation == DeviceOrientation.LandscapeLeft || Input.deviceOrientation == DeviceOrientation.LandscapeRight)
		{
			defGravity = 0;
		}
		if (Player.speed < 10 && AI1.speed > 10)
		{
			Player.CancelInvoke("accel");
			Player.CancelInvoke("touch");
			Player.CancelInvoke("uni");
			lose.active = true;
			if ((bool)threeround)
			{
				threeround.aipoints++;
				StartCoroutine(threeround.finished());
			}
			stat = 0;
			CancelInvoke();
		}
		if ((bool)AI2)
		{
			if (Player.speed < 10 && AI2.speed > 10)
			{
				Player.CancelInvoke("accel");
				Player.CancelInvoke("touch");
				Player.CancelInvoke("uni");
				lose.active = true;
				if ((bool)threeround)
				{
					threeround.aipoints++;
					StartCoroutine(threeround.finished());
				}
				stat = 0;
				CancelInvoke();
			}
			if (Player.speed < 10 && AI3.speed > 10)
			{
				Player.CancelInvoke("accel");
				Player.CancelInvoke("touch");
				Player.CancelInvoke("uni");
				lose.active = true;
				if ((bool)threeround)
				{
					threeround.aipoints++;
					StartCoroutine(threeround.finished());
				}
				stat = 0;
				CancelInvoke();
			}
			if (Player.speed > 10 && AI1.speed < 10 && AI2.speed < 10 && AI3.speed < 10)
			{
				Player.CancelInvoke("accel");
				Player.CancelInvoke("touch");
				Player.CancelInvoke("uni");
				win.active = true;
				if (defGravity == 1)
				{
					JCAchievementMunger.UnlockAchievement("CgkI3_DHnsgeEAIQEw");
				}
				if ((bool)threeround)
				{
					threeround.playerpoints++;
					StartCoroutine(threeround.finished());
				}
				stat = 0;
				CancelInvoke();
			}
			if (Player.speed == 0 && AI1.speed == 0 && AI2.speed == 0 && AI3.speed == 0)
			{
				Player.CancelInvoke("accel");
				Player.CancelInvoke("touch");
				Player.CancelInvoke("uni");
				win.active = true;
				if (defGravity == 1)
				{
					JCAchievementMunger.UnlockAchievement("CgkI3_DHnsgeEAIQEw");
				}
				if ((bool)threeround)
				{
					threeround.playerpoints++;
					StartCoroutine(threeround.finished());
				}
				stat = 0;
				CancelInvoke();
			}
		}
		if ((bool)AI2)
		{
			return;
		}
		if (Player.speed > 10 && AI1.speed < 10)
		{
			Player.CancelInvoke("accel");
			Player.CancelInvoke("touch");
			Player.CancelInvoke("uni");
			win.active = true;
			if (defGravity == 1)
			{
				JCAchievementMunger.UnlockAchievement("CgkI3_DHnsgeEAIQEw");
			}
			if ((bool)threeround)
			{
				threeround.playerpoints++;
				StartCoroutine(threeround.finished());
			}
			stat = 0;
			CancelInvoke();
		}
		if (Player.speed == 0 && AI1.speed == 0)
		{
			Player.CancelInvoke("accel");
			Player.CancelInvoke("touch");
			Player.CancelInvoke("uni");
			win.active = true;
			if (defGravity == 1)
			{
				JCAchievementMunger.UnlockAchievement("CgkI3_DHnsgeEAIQEw");
			}
			if ((bool)threeround)
			{
				threeround.playerpoints++;
				StartCoroutine(threeround.finished());
			}
			stat = 0;
			CancelInvoke();
		}
	}

	public IEnumerator state()
	{
		return new _0024state_0024503(this).GetEnumerator();
	}

	public IEnumerator find()
	{
		return new _0024find_0024506(this).GetEnumerator();
	}

	public void Main()
	{
		InvokeRepeating("wld", 7f, 0.7f);
	}
}
